from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from app.routers import chat

app = FastAPI(
    title="FinChat API",
    description="基于记账数据的AI对话系统",
    version="1.0"
)

# 配置CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 包含路由
app.include_router(chat.router, prefix="/api", tags=["chat"])

@app.get("/")
def health_check():
    return {"status": "ok", "message": "FinChat API is running"}